package stubs;

/**
 * 
 * @author vincenzo.delia@polito.it
 *
 */
import java.util.Map;
import java.util.TreeMap;


import mystubs.CRoom;
import mystubs.Env;
import mystubs.PhysBoiler;

public class PhysicalFactory {
	private static IPhysicalEnvironment env = null;
	private static Map<String,IPhysicalRoom> rooms = new TreeMap<String, IPhysicalRoom>();
	
	private static IPhysicalBoiler boiler = null;
	
	public static IPhysicalRoom getPhysicalRoom(String name, int sqm) {
		IPhysicalRoom room;
		if (!rooms.containsKey(name)) {
			room = new CRoom(getPhysicalEnvironment(), getPhysicalBoiler());
			rooms.put(name, room);
		} else {
			room = rooms.get(name);
		}
		return room;
	}
	
	public static IPhysicalEnvironment getPhysicalEnvironment() {
		if (env==null) {
			env = new Env();
		}
		return env;
	}
	
	public static IPhysicalBoiler getPhysicalBoiler() {
		if (boiler==null) {
			boiler = new PhysBoiler();
		}
		return boiler;
	}
}
